home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / doExtendSurfaceArgList.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  5.3 KB  |  181 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Mar. 14, 1999
  22. //  Author:         ms
  23. //
  24. //  Description:
  25. //      The doExtendSurfaceArgList() procedure executes a extend operation on
  26. //        each selected object based on the extend option vars.
  27. //
  28. //  Input Arguments:
  29. //      None.
  30. //
  31. //  Versions:
  32. //      1 - Maya V2
  33.  
  34. proc string prepareExtendSurface( string $version, string $args[],
  35.                                   int $forSurface )
  36. {
  37.  
  38.     string $cmd = "";
  39.     int $need = 0;
  40.     if( "1" == $version ) {
  41.         $need = 8;
  42.     }
  43.     else {
  44.         warning( "Bad version for doExtendSurfaceArgList. Assuming version 1.");
  45.         $version = "1";
  46.         $need = 8;
  47.     }
  48.  
  49.     if( size($args) < $need ) {
  50.         error( "Not enough arguments to doExtendSurfaceArgList" );
  51.         return $cmd;
  52.     }
  53.  
  54.     // Set up command strings for each command.
  55.     string $cmd = "extendSurface";
  56.     $cmd = $cmd + " -ch " + $args[0];
  57.     $cmd = $cmd + " -em " + $args[1];
  58.     $cmd = $cmd + " -et " + $args[2];
  59.     $cmd = $cmd + " -d " + $args[3];
  60.     $cmd = $cmd + " -jn " + $args[5];
  61.  
  62.     // If join is not set, force keep originals (rpo off)
  63.     string $rpo = $args[6];
  64.     int $join = $args[5];
  65.     if( !$join ) {
  66.         $rpo = "off";
  67.     }
  68.  
  69.     $cmd = $cmd + " -rpo " + $rpo;
  70.     if( $forSurface ) {
  71.         $cmd = $cmd + " -es " + $args[4];
  72.         $cmd = $cmd + " -ed " + $args[7];
  73.     }
  74.     $cmd = $cmd + " ";
  75.  
  76.     return $cmd;
  77. }
  78.  
  79. global proc doExtendSurfaceArgList( string $version, string $args[] )
  80. {
  81.     string $cmd = prepareExtendSurface( $version, $args, 1 );
  82.     if( "" == $cmd ) return;
  83.  
  84.     // Get a list of each type of acceptable object type - surfaces+iso.
  85.     //
  86.     global int $gSelectNurbsSurfacesBit;
  87.     global int $gSelectIsoparmsBit;
  88.  
  89.     string $surfaceList[] =`filterExpand -ex true -sm $gSelectNurbsSurfacesBit`;
  90.     string $isoList[] = `filterExpand -ex true -sm $gSelectIsoparmsBit`;
  91.  
  92.     $cmd += " %s;";
  93.     string $surfaceResults[] = executeForEachObject( $surfaceList, $cmd );
  94.  
  95.     // Processing isoparms is a little more involved.  Use groupObjectsByName().
  96.     // This big loop groups and processes >1 isoparms and sets the
  97.     // direction of the command based on the isoparm direction.
  98.     // Also, if the user selects an isoparm in each direction on the same
  99.     // surface, this code assumes that the user wants to extend the
  100.     // surface in BOTH directions.
  101.     //
  102.  
  103.     $cmd = prepareExtendSurface( $version, $args, 0 );
  104.  
  105.     string $isoparmResults[];
  106.     string $isoparms[] = groupObjectsByName( $isoList, "\\." );
  107.     int $numIsoStrs = size($isoparms);
  108.     for( $i = 0; $i < $numIsoStrs; $i ++ ) {
  109.  
  110.         string $extendCmd;
  111.         string $results[];
  112.         string $objectName[];
  113.  
  114.         $numNames = `tokenize $isoparms[$i] "\\." $objectName`;
  115.         if( $numNames == 1 )  {
  116.             $extendCmd = $cmd + $isoparms[$i];
  117.         }
  118.         else {
  119.             string $foundU = `match "\\.u\\[" $isoparms[$i]`;
  120.             string $foundV = `match "\\.v\\[" $isoparms[$i]`;
  121.             if( size($foundU) > 0 && size($foundV) > 0 ) {
  122.                 $extendCmd = $cmd + "-ed 2 " + $objectName[0];
  123.             }
  124.             else if( size($foundU) > 0 ) {
  125.                 $extendCmd = $cmd + "-ed 0 " + $objectName[0];
  126.             }
  127.             else if( size($foundV) > 0 ) {
  128.                 $extendCmd = $cmd + "-ed 1 " + $objectName[0];
  129.             }
  130.         }
  131.  
  132.         if( catch( $results = evalEcho( $extendCmd )) ) {
  133.             error(" Problem executing extend command: " + $extendCmd);
  134.         }
  135.         else {
  136.             int $j;
  137.             int $numResults = size( $results );
  138.             int $numIsoResults = size( $isoparmResults );
  139.             for( $j = 0; $j < $numResults; $j ++, $numIsoResults ++ ) {
  140.                 $isoparmResults[$numIsoResults] = $results[$j];
  141.             }
  142.         }
  143.     }
  144.  
  145.     // Process all the results - if there weren't any then display a error
  146.     //
  147.     if( 0 == (size($surfaceResults) + size($isoparmResults)) ) {
  148.         if( 0 == (size($surfaceList) + size($isoList)) ) {
  149.             error ("Nothing was selected to extend.  Select surfaces " +
  150.                    "or surface isoparm.");
  151.         }
  152.         else {
  153.             warning( "Extend surface operation produced no results." );
  154.         }
  155.     } else {
  156.         // Select all the results with one select command.  Note that only
  157.         // resulting surfaces and curves are selected, not dependency nodes.
  158.         //
  159.         string $selectString;
  160.         $selectString = "select ";
  161.         int $i;
  162.  
  163.         int $numSurfaces = size($surfaceResults);
  164.         for( $i = 0; $i < $numSurfaces; $i ++ ) {
  165.             $selectString += $surfaceResults[$i];
  166.             $selectString += " ";
  167.         }
  168.  
  169.         int $numIsos = size($isoparmResults);
  170.         for( $i = 0; $i < $numIsos; $i ++ ) {
  171.             $selectString += $isoparmResults[$i];
  172.             $selectString += " ";
  173.         }
  174.  
  175.         $selectString += ";";
  176.         select -cl;
  177.         eval($selectString);
  178.     }
  179. }
  180.  
  181.